<?php
/**
 * index page
 *
 * @author Jensen
 */
class movie_list extends AbstractAction {

    public function run() {
        global $TPL, $filters;

        $page = intval($_GET['p']);
        if (empty($page)) {
            $page = 1;
        }
        
        // set filters
        $TPL->assign('filters', $this->getFilterValues() );

        $movieDAO = $this->getDao("MovieDAO");
        $items = $movieDAO->GetAllItems( MOVIE_PERPAGE, $page );
        foreach( $items as &$item ){
            $item['title_plain'] = $item['title'];
            
            // set large images
            $item['largeImgUrl'] = $this->getLargeImgUrl($item['imgUrl']);
        }
        // pager information
        $totalCount = $movieDAO->GetAllItemsCount();
        if (debug) {
            $pager = new Pager('index.php?action=movie_list', $totalCount, MOVIE_PERPAGE, $page, 'p');
        } else {
            $pager = new Pager(__CLASS__, $totalCount, MOVIE_PERPAGE, $page, 'p');
        }
        
        // get search history
        $searchHistoryDao = $this->getDao("SearchHistoryDAO");
        $searchhistory = $searchHistoryDao->GetAllItems();
        $TPL->assign('searchhistory', $searchhistory );
        
        // process actors and movie type
        
        
        $TPL->assign('current_page', 'movie_list');
        $TPL->assign('items', $items);
        $TPL->assign('pager', $pager->getBar());
        
        
//        $TPL->display('advanced_search.tpl');
        $TPL->display('theme_v2/list.tpl');
    }

}

?>
